﻿<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="teacher_manage.aspx.cs" Inherits="score_m.teacher_manage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>教师管理</title>
    <link rel="stylesheet" href="resource/sweetalert-11.4.14/sweetalert2.css" />
    <script src="resource/sweetalert-11.4.14/sweetalert2.js"></script>
    <link rel="stylesheet" href="resource/css/base.css" />
    <style>
        .cont {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
        }

        .nav {
            display: flex;
            border-bottom: 1px solid var(--base_border_color);
            margin-bottom: 10px;
        }

        .nav div {
            padding: 8px 20px;
            cursor: pointer;
            border: 1px solid transparent;
            border-bottom: none;
            margin-bottom: -1px;
            position: relative;
        }

        .nav div.active {
            background-color: white;
            border-color: var(--base_border_color);
            border-radius: 4px 4px 0 0;
        }

        .nav div.active::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 0;
            right: 0;
            height: 1px;
            background-color: white;
        }

        .show-cont, .add-cont {
            flex: 1;
            display: none;
            background-color: white;
            border: 1px solid var(--base_border_color);
            border-radius: 0 4px 4px 4px;
            padding: 15px;
        }

        .show-cont.active, .add-cont.active {
            display: block;
        }

        .select-cont {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
        }

        .select-item {
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .select-item span {
            width: 80px;
            text-align: right;
        }

        .table-box {
            width: 100%;
            height: calc(100% - 50px);
            overflow: auto;
        }

        .insert-form {
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-width: 500px;
        }

        .insert-form-item {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .insert-form-item span {
            width: 80px;
            text-align: right;
        }

        .insert-form-item input, .insert-form-item select {
            flex: 1;
            padding: 5px;
            border: 1px solid var(--base_border_color);
            border-radius: 3px;
        }

        .insert-form-item input:focus, .insert-form-item select:focus {
            outline: none;
            border-color: var(--base_active_color);
        }

        .submit-item {
            margin-top: 10px;
        }
    </style>
    <script>
        const Toast = Swal.mixin({
            toast: true,
            position: 'top-end',
            showConfirmButton: false,
            timer: 3000,
            timerProgressBar: true
        });

        function changeFunc(type) {
            if (type === 'show') {
                document.querySelector('.show-cont').classList.add('active');
                document.querySelector('.add-cont').classList.remove('active');
                document.querySelector('.nav div:first-child').classList.add('active');
                document.querySelector('.nav div:last-child').classList.remove('active');
            } else {
                document.querySelector('.show-cont').classList.remove('active');
                document.querySelector('.add-cont').classList.add('active');
                document.querySelector('.nav div:first-child').classList.remove('active');
                document.querySelector('.nav div:last-child').classList.add('active');
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="cont">
            <div class="nav">
                <div onclick="changeFunc('show')" class="active">查询</div>
                <div onclick="changeFunc('add')">添加</div>
            </div>
            <div class="show-cont active">
                <asp:UpdatePanel runat="server" ID="UpdatePanel1">
                    <ContentTemplate>
                        <div class="select-cont">
                            <div class="select-item">
                                <span>查询条件:</span>
                                <div>
                                    <asp:DropDownList ID="searchDropList" runat="server">
                                        <asp:ListItem Value="name">姓名</asp:ListItem>
                                        <asp:ListItem Value="teacher_id">工号</asp:ListItem>
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="select-item">
                                <div>
                                    <asp:TextBox ID="searchInput" runat="server"></asp:TextBox>
                                </div>
                            </div>
                            <div class="select-item">
                                <div>
                                    <asp:Button ID="searchBtn" runat="server" Text="查询" OnClick="searchBtn_Click" CssClass="primary-button" />
                                </div>
                            </div>
                        </div>
                        <div class="table-box">
                            <asp:GridView ID="teacherGridView" runat="server" AutoGenerateColumns="False" 
                                DataKeyNames="teacher_id"
                                OnRowDeleting="teacherGridView_RowDeleting"
                                OnRowEditing="teacherGridView_RowEditing" OnRowCancelingEdit="teacherGridView_RowCancelingEdit"
                                OnRowUpdating="teacherGridView_RowUpdating" CellPadding="4" ForeColor="#333333" GridLines="None">
                                <AlternatingRowStyle BackColor="White" />
                                <Columns>
                                    <asp:BoundField DataField="teacher_id" HeaderText="工号" ReadOnly="true" />
                                    <asp:TemplateField HeaderText="姓名">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="nameEditInput" runat="server" Text='<%# Bind("name") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="部门">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="departmentEditInput" runat="server" Text='<%# Bind("department") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="departmentLabel" runat="server" Text='<%# Bind("department") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="操作">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="editBtn" runat="server" CommandName="Edit" Text="编辑" CssClass="edit-btn"></asp:LinkButton>
                                            <asp:LinkButton ID="deleteBtn" runat="server" CommandName="Delete" Text="删除" CssClass="delete-btn"
                                                OnClientClick="return confirm('确定要删除该教师吗？');"></asp:LinkButton>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:LinkButton ID="updateBtn" runat="server" CommandName="Update" Text="更新" CssClass="edit-btn"></asp:LinkButton>
                                            <asp:LinkButton ID="cancelBtn" runat="server" CommandName="Cancel" Text="取消" CssClass="delete-btn"></asp:LinkButton>
                                        </EditItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <EditRowStyle BackColor="#F5F7FA" />
                                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#EFF3FB" />
                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                <SortedDescendingHeaderStyle BackColor="#4870BE" />
                            </asp:GridView>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="searchBtn" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
            <div class="add-cont">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server" class="insert-cont">
                    <ContentTemplate>
                        <div class="insert-form">
                            <div class="insert-form-item">
                                <span>工号:</span>
                                <asp:TextBox ID="teacherIdInput" runat="server"></asp:TextBox>
                            </div>
                            <div class="insert-form-item">
                                <span>姓名:</span>
                                <asp:TextBox ID="nameInput" runat="server"></asp:TextBox>
                            </div>
                            <div class="insert-form-item">
                                <span>部门:</span>
                                <asp:TextBox ID="departmentInput" runat="server"></asp:TextBox>
                            </div>
                            <div class="insert-form-item">
                                <span>密码:</span>
                                <asp:TextBox ID="passwordInput" runat="server" TextMode="Password"></asp:TextBox>
                            </div>
                            <div class="insert-form-item submit-item">
                                <asp:Button ID="saveBtn" runat="server" Text="添加" OnClick="saveBtn_Click" CssClass="primary-button" />
                            </div>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </form>
</body>
</html> 